/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jakroatis;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Jose Carlos Palma
 */
public abstract class ThreadPlus extends Thread{
    
    private boolean shutdown = false;
    
    private boolean running = false;
    
    
    public ThreadPlus(String name){
        super(name);
    }

    public void shutdown() {
        this.shutdown = true;
    }

    @Override
    public final void run() {
        System.out.printf("%s [%s]\n", getName(), "On");
        running = true;
        while( !isShutdown() ){
            core();
        }
        running = false;
    }
    
    public abstract void core();
    
    public abstract void serviceStatus();
    
    public abstract void serviceStart();
    
    public abstract void serviceRestart();
    
    public abstract void serviceStop();
    

    /**
     * @return the shutdown
     */
    public boolean isShutdown() {
        return shutdown;
    }

    /**
     * @return the running
     */
    public boolean isRunning() {
        return running;
    }

    
    
    public void pause(long millis){
        try {
            sleep(millis);
        } catch (InterruptedException ex) {}
    }
    
}
